package cn.itcast.feign;

import cn.config.Configuration1;
import cn.itcast.entity.User;
import cn.itcast.hystrix.HystrixClientFallbackFactory;
import feign.Param;
import feign.RequestLine;
import org.springframework.cloud.netflix.feign.FeignClient;

/**
 * @Author: zhaojie
 * @Date: Created in 16:07 2018/7/21
 * @Description: 使用feign调用 user微服务
 * 需要在name中指定访问的serviceName  可以不用指定url
 * feign对hystrix的支持需要添加fallback = HystrixClientFallback.class
 * 使用 fallbackFactory时不能使用fallback
 */
@FeignClient(name = "car-manager-user", configuration = Configuration1.class
       /* fallback = HystrixClientFallback.class*/, fallbackFactory = HystrixClientFallbackFactory.class)
public interface UserFeignClient {
    /**
     * 需要使用RequestLine注解 并在路径前写入 请求方式
     *
     * @param id
     * @return http://car-manager-user/simple/{id}
     */
    @RequestLine("GET /simple/{id}")
    public User get(@Param("id") Long id);
}
